package com.liliya.service.impl;

import com.liliya.dao.UserDao;
import com.liliya.dao.impl.UserDaoImpl;
import com.liliya.pojo.User;
import com.liliya.service.UserService;

import java.util.List;

/**
 * @Description TODO
 * @Author hhy
 * @Date 2021/1/5 15:23
 */
public class UserServiceImpl implements UserService {
    private UserDao userDao = new UserDaoImpl();
    @Override
    public User findUserByName(String name) {
        return userDao.findUserByName(name);
    }

    @Override
    public void addUser(User user) {
        userDao.addUser(user);
    }

    @Override
    public List<User> findUsers(Integer start, Integer end) {
        return userDao.findUsers(start,end);
    }

    @Override
    public Integer findUsersCount() {
        return userDao.findUsersCount();
    }

    @Override
    public Integer findPage(Integer step) {
        Integer page = null;
        Integer total = findUsersCount();
        if (total%step==0){
            page = total/step;
        }else {
            page = total/step + 1;
        }
        return page;
    }

    @Override
    public void deleteUser(String username) {
        userDao.deleteUser(username);
    }


}
